package cn.lili.event.impl;

import cn.lili.event.TradeEvent;
import cn.lili.modules.order.cart.entity.dto.TradeDTO;
import cn.lili.modules.order.trade.client.TradeClient;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

/**
 * 订单状态处理类
 *
 * @author Chopper
 * @since 2020-07-03 11:20
 */
@Service
@RequiredArgsConstructor
public class OrderStatusHandlerExecute implements TradeEvent {

    private final TradeClient tradeClient;

    @Override
    public void tradeCreate(TradeDTO tradeDTO) {
        // 如果订单需要支付金额为0，则将订单步入到下一个流程
        if (tradeDTO.getPriceDetailDTO().getFlowPrice() <= 0) {
            tradeClient.paymentCallbackZero(tradeDTO.getSn());
        }
    }
}
